<?php

namespace App\Controllers;

use App\Models\User;

class NotesController extends Controller
{
    public function create()
    {
        render('pages.notes.create');
    }

    public function store()
    {
        $data = request()->get(['title', 'note']);

        User::find(auth()->id())->notes()->create($data);

        return response()
            ->withFlash('leaf.toast', [
                'title' => 'Note created',
                'type' => 'success',
            ])
            ->redirect('/dashboard');
    }
}
